package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicProductBomMaterialsDAO;
import com.cssy.xxkj.basic.entity.BasicProductBomMaterialsDO;
import com.cssy.xxkj.logic.entity.vo.UtilsEntityVO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-19
 */
public class BasicProductBomMaterialsDAOImpl extends SqlMapClientDaoSupport implements BasicProductBomMaterialsDAO {

    /**
     * 插入数据
     * @param basicProductBomMaterialsDO
     * @return 插入数据的主键
     */
    public String insertBasicProductBomMaterialsDO(BasicProductBomMaterialsDO basicProductBomMaterialsDO) {
        Object id = getSqlMapClientTemplate().insert("BasicProductBomMaterials.insert", basicProductBomMaterialsDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicProductBomMaterialsDO
     * @return 查出的记录数
     */
    public Integer countBasicProductBomMaterialsDOByExample(BasicProductBomMaterialsDO basicProductBomMaterialsDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicProductBomMaterials.countByDOExample", basicProductBomMaterialsDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicProductBomMaterialsDO
     * @return 受影响的行数
     */
    public Integer updateBasicProductBomMaterialsDO(BasicProductBomMaterialsDO basicProductBomMaterialsDO) {
        int result = getSqlMapClientTemplate().update("BasicProductBomMaterials.update", basicProductBomMaterialsDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicProductBomMaterialsDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicProductBomMaterialsDO> findListByExample(BasicProductBomMaterialsDO basicProductBomMaterialsDO) {
        List<BasicProductBomMaterialsDO> list = getSqlMapClientTemplate().queryForList("BasicProductBomMaterials.findListByDO", basicProductBomMaterialsDO);
        return list;
    }

    /**
     * 根据主键获取basicProductBomMaterialsDO
     * @param id
     * @return basicProductBomMaterialsDO
     */
    public BasicProductBomMaterialsDO findBasicProductBomMaterialsDOByPrimaryKey(String id) {
        BasicProductBomMaterialsDO basicProductBomMaterialsDO = (BasicProductBomMaterialsDO) getSqlMapClientTemplate().queryForObject("BasicProductBomMaterials.findByPrimaryKey", id);
        return basicProductBomMaterialsDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicProductBomMaterialsDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicProductBomMaterials.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public Integer deleteBomId(String id) {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicProductBomMaterials_ex.deletebomId", id);
        return rows;
	}

	@Override
	public List<UtilsEntityVO> findAllList(SearchConditions scs) {
		
		return getSqlMapClientTemplate().queryForList("BasicProductBomMaterials_ex.findAll",scs);
	}

}